package com.nextStep.Aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Component
@Aspect
public class UserAspect {

    @Before("execution(* com.nextStep.service..*(..))")
    public void befor(JoinPoint joinPoint) throws IOException {
        joinPoint.getSignature().getName();    //获得调用方法名
        System.out.println("前置通知生效");
    }

    @AfterReturning("execution(* com.nextStep.service..*(..))")
    public void after(JoinPoint joinPoint){

    }

    @AfterThrowing(value = "execution(* com.nextStep.service..*(..))" ,throwing = "e")
    public void aftherThread(Exception e){
        System.out.println("异常通知"+e.getMessage());
    }


}
